<?php

class logger_hook
{
	public function __construct()
	{
		Event::add('system.post_controller', array($this, 'log'));
	}
	
	public function log()
	{
		$exclude = Kohana::config('access-log.exclude');

		$log = TRUE;
		foreach ($exclude as $item)
		{
			if (count($item) === 1 AND Router::$controller == $item[0]) // Exclude an entire controller
				$log = FALSE;
			elseif (count($item) === 2 AND Router::$controller == $item[0] AND Router::$method == $item[1])
				$log = FALSE;
		}

		if ($log)
			Access_logger::add();
	}
}

new logger_hook;